<?php
/**
 * Created by PhpStorm.
 * User: THUNDEROBOT
 * Date: 2021/1/15
 * Time: 10:29
 */

namespace app\admin\controller;

use app\admin\model\Form;
use think\Request;
use think\Controller;

class Forms extends Controller
{
    public function index(){
        $formModel = new Form();
        $formList = $formModel->form();
//         dump($formList->toArray());
        $emptyHtml = '<tr><td align="center" colspan="5">暂无任何数据</td></tr>';
        $this->assign("emptyHtml",$emptyHtml);
        $this->assign("formList",$formList);
        return $this->fetch();
    }

    //提交新增作业表单
    public function doAddform(){
        if(Request::instance()->isPost()){
            $data = Request::instance()->post();
//        dump($data);

            $userModel = new Form();
            $res = $userModel->addform($data);
            if($res > 0){
                echo '交卷成功！';


            }else{
                $this->error("提交失败");
            }
        }else{
            $this->error("操作失败");
        }
    }
}